package com.google.code.motoo.sample.press;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class CountClient {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	public static void main(String[] args) throws Exception {
		int size = 100;
		long total = 0;
		Socket socket = new Socket("192.168.1.210", 9000);
		BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		PrintStream out = new PrintStream(socket.getOutputStream());
		for (int i = 0; i < size; i++) {
			long start = System.currentTimeMillis();
			out.println("testtest");
			out.flush();
			String content = in.readLine();
			long end = System.currentTimeMillis();
			long spend = end - start;
			total += spend;
			System.out.println("time : " + spend + ", content : " + content);
		}
		
		System.out.println("mean time : " + (total / size));

	}

}
